/***********************************************************************
 * Module:  Lecturer.java
 * Author:  DAC
 * Purpose: Defines the Class Lecturer
 ***********************************************************************/
package com.group1.model;
import java.util.*;

import org.hibernate.Query;
import org.hibernate.Session;

/** @pdOid 90f88957-8b58-4b98-9680-26a487e59df7 */
public class Lecturer {
   /** @pdOid 1703650f-a949-4c7f-bbd6-012e4e112f33 */
   protected void finalize() {
      // TODO: implement
   }
   
   /** @pdOid 36ceeb7d-34d8-4d7d-8fab-788165b894b4 */
   public java.lang.String lecturerId;
   /** @pdOid 37d6902e-5a2b-4d16-a64a-c8178e89cb7f */
   public java.lang.String lecturerName;
   
   /** @pdRoleInfo migr=no name=Subject assc=subjectOfLecturer coll=java.util.Collection impl=java.util.HashSet mult=0..* */
//   public java.util.Collection<Subject> lecturerSubjectMapping;
   private Set lecturerSubjectMapping = new HashSet(0);
   /** @pdRoleInfo migr=no name=Question assc=creatorOfQuestions coll=java.util.Collection impl=java.util.HashSet mult=0..* */
   public java.util.Collection<Question> question;
   
   /** @pdOid 67994c0f-2360-491c-84a0-1f07326a5825 */
   public java.lang.String getLecturerId() {
      return lecturerId;
   }
   
   public static Lecturer getLecturerByID(Session session, String lecturerID)
   {
	   return (Lecturer) session.load(Lecturer.class, lecturerID);
   }
   
   /** @param newLecturerId
    * @pdOid 3a323f17-64c8-45d2-8bf6-1ac762c6c421 */
   public void setLecturerId(java.lang.String newLecturerId) {
      lecturerId = newLecturerId;
   }
   
   /** @pdOid 9f690016-47b6-4bcf-a317-4e3e3745c296 */
   public Lecturer() {
      // TODO: implement
   }
   
   /** @pdOid c1617fb3-8c87-4f53-bbda-4c83550360be */
   public java.lang.String getLecturerName() {
      return lecturerName;
   }
   
   /** @param newLecturerName
    * @pdOid e59d14ab-f7de-4e99-a06a-6844ea22fa69 */
   public void setLecturerName(java.lang.String newLecturerName) {
      lecturerName = newLecturerName;
   }
   
   
//   /** @pdGenerated default getter */
//   public java.util.Collection<Subject> getLecturerSubjectMapping() {
//      return lecturerSubjectMapping;
//   }
	public Set getLecturerSubjectMapping() {
		return this.lecturerSubjectMapping;
	}

	public void setLecturerSubjectMapping(Set lecturerSubjectMapping) {
		this.lecturerSubjectMapping = lecturerSubjectMapping;
	}
   /** @pdGenerated default iterator getter */
   public java.util.Iterator getIteratorLecturerSubjectMapping() {
      if (lecturerSubjectMapping == null)
         lecturerSubjectMapping = new java.util.HashSet<Subject>();
      return lecturerSubjectMapping.iterator();
   }
   
//   /** @pdGenerated default setter
//     * @param newLecturerSubjectMapping */
//   public void setLecturerSubjectMapping(java.util.Collection<Subject> newLecturerSubjectMapping) {
//      removeAllLecturerSubjectMapping();
//      for (java.util.Iterator iter = newLecturerSubjectMapping.iterator(); iter.hasNext();)
//         addLecturerSubjectMapping((Subject)iter.next());
//   }
   
   /** @pdGenerated default add
     * @param newSubject */
   public void addLecturerSubjectMapping(Subject newSubject) {
      if (newSubject == null)
         return;
      if (this.lecturerSubjectMapping == null)
         this.lecturerSubjectMapping = new java.util.HashSet<Subject>();
      if (!this.lecturerSubjectMapping.contains(newSubject))
      {
         this.lecturerSubjectMapping.add(newSubject);
         newSubject.addLecturerSubjectMapping(this);      
      }
   }
   
   /** @pdGenerated default remove
     * @param oldSubject */
   public void removeLecturerSubjectMapping(Subject oldSubject) {
      if (oldSubject == null)
         return;
      if (this.lecturerSubjectMapping != null)
         if (this.lecturerSubjectMapping.contains(oldSubject))
         {
            this.lecturerSubjectMapping.remove(oldSubject);
            oldSubject.removeLecturerSubjectMapping(this);
         }
   }
   
   /** @pdGenerated default removeAll */
   public void removeAllLecturerSubjectMapping() {
      if (lecturerSubjectMapping != null)
      {
         Subject oldSubject;
         for (java.util.Iterator iter = getIteratorLecturerSubjectMapping(); iter.hasNext();)
         {
            oldSubject = (Subject)iter.next();
            iter.remove();
            oldSubject.removeLecturerSubjectMapping(this);
         }
      }
   }
   
   /** @pdGenerated default getter */
   public java.util.Collection<Question> getQuestion() {
      return question;
   }
   
   /** @pdGenerated default iterator getter */
   public java.util.Iterator getIteratorQuestion() {
      if (question == null)
         question = new java.util.HashSet<Question>();
      return question.iterator();
   }
   
   /** @pdGenerated default setter
     * @param newQuestion */
   public void setQuestion(java.util.Collection<Question> newQuestion) {
      this.question = newQuestion;
   }
   
   /** @pdGenerated default add
     * @param newQuestion */
   public void addQuestion(Question newQuestion) {
      if (newQuestion == null)
         return;
      if (this.question == null)
         this.question = new java.util.HashSet<Question>();
      if (!this.question.contains(newQuestion))
      {
         this.question.add(newQuestion);
         newQuestion.setLecturer(this);      
      }
   }
   
   /** @pdGenerated default remove
     * @param oldQuestion */
   public void removeQuestion(Question oldQuestion) {
      if (oldQuestion == null)
         return;
      if (this.question != null)
         if (this.question.contains(oldQuestion))
         {
            this.question.remove(oldQuestion);
            oldQuestion.setLecturer((Lecturer)null);
         }
   }
   
   /** @pdGenerated default removeAll */
   public void removeAllQuestion() {
      if (question != null)
      {
         Question oldQuestion;
         for (java.util.Iterator iter = getIteratorQuestion(); iter.hasNext();)
         {
            oldQuestion = (Question)iter.next();
            iter.remove();
            oldQuestion.setLecturer((Lecturer)null);
         }
      }
   }

}